package javabasic.threads.getsubthreadvalue;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class JoinGet {
    public static void main(String[] args) {
        GetSub03 getSub03 = new GetSub03();
        FutureTask<String> stringFutureTask = new FutureTask<String>(getSub03);
        Thread thread = new Thread(stringFutureTask);
        thread.start();
        try {
            thread.join();
            try {
                System.out.println(stringFutureTask.get());
            } catch (ExecutionException e) {
                e.printStackTrace();
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}
class GetSub03 implements Callable{
    @Override
    public Object call() throws Exception {
        Thread.sleep(100);
        return "sub thread value";
    }
}
